package weibo4j.util;

import com.nmp.config.CommonConfig;
import com.nmp.web.listener.SpringBeanManager;



public class WeiboConfig {
	
	public static final String CONSUMER_KEY = "2947086056";
	public static final String CONSUMER_SECRET = "87e60d232be6a39e2a0c93e23caf850b";
	public static String REDIRECT_URI = null;
	public static final String BASE_URL = "https://api.weibo.com/2/";
	public static final String ACCESS_TOKEN_URL = "https://api.weibo.com/2/oauth2/access_token";
	public static final String AUTHORIZATION_URL = "https://api.weibo.com/2/oauth2/authorize";
	
	public WeiboConfig(){
		
	}
	
	public static String getValue(String key) {
		
		if(key.equalsIgnoreCase("client_ID")) {
			return CONSUMER_KEY;
		} else if(key.equalsIgnoreCase("client_SERCRET")) {
			return CONSUMER_SECRET;
		} else if(key.equalsIgnoreCase("redirect_URI")) {
			if(REDIRECT_URI == null) {
				REDIRECT_URI = ((CommonConfig)SpringBeanManager.getBean("commonConfig")).getSinaCallback();
			}
			return REDIRECT_URI;
		} else if(key.equalsIgnoreCase("baseURL")) {
			return BASE_URL;
		} else if(key.equalsIgnoreCase("accessTokenURL")) {
			return ACCESS_TOKEN_URL;
		} else if(key.equalsIgnoreCase("authorizeURL")) {
			return AUTHORIZATION_URL;
		} else {
			throw new IllegalArgumentException("config params is not exists:"+key);
		}
	}
   
}
